/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *//*

package cz.worsik.android.test.rideshare.util.listener;

import android.view.View;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import cz.worsik.android.test.rideshare.R;
import cz.worsik.android.test.rideshare.MainActivity;
import cz.worsik.android.test.rideshare.constants.ViewConst;

public class SaveOnClickListener implements View.OnClickListener 
{ 
	MainActivity a;
	View layout;

	public SaveOnClickListener(MainActivity a, View layout) {
		this.a = a;
		this.layout = layout;
	}
	
	public void onClick(View v) {

		// error text pro return
		String error = "\n";

		// objekty
		Spinner ridic_select = (Spinner) layout.findViewById(R.id.driver_select);
		RadioButton tam_btn = (RadioButton) layout.findViewById(R.id.tam);
		RadioButton zpet_btn = (RadioButton) layout.findViewById(R.id.zpet);

		// kontrola checkboxu
		int passenger_count = 0;
		String[] passengers = new String[ViewConst.CHECKBOX_COUNT];
		for (int i=1; i<ViewConst.CHECKBOX_COUNT; i++)
		{
			CheckBox check = (CheckBox) layout.findViewById(ViewConst.CHECKBOX_START_ID+i);
			if (check.isChecked())
			{
				passengers[passenger_count] = check.getText().toString();
				passenger_count ++;
			}
		}
		if (passenger_count == 0)
		{
			error += a.getString(R.string.err_no_passenger_selected)+"\n";
		}

		// kontrola zadani smeru
		TextView smer_view = null;
		if (tam_btn.isChecked()) {
			smer_view = (TextView) layout.findViewById(R.id.tam_label);
		}
		else if (zpet_btn.isChecked()) {
			smer_view = (TextView) layout.findViewById(R.id.zpet_label);
		}
		else
		{
			error += a.getString(R.string.err_no_direction_selected)+"\n";
		}

		// kontrola a pripadne vyhozeni ven
		if (!"\n".equals(error))
		{
			a.showToast(error);
			return;
		}

		// hodnoty k pouziti
		String ridic = ridic_select.getSelectedItem().toString();
		String smer = smer_view.getText().toString().trim();
		String datum = ""+a.getRok()+"-"+a.getCisloMesice()+"-"+a.getDen();

		a.getDb().open();
		Boolean splneno = a.getDb().saveDriveWay(ridic, datum, smer, passenger_count, passengers);
		a.getDb().close();

		String text;
		if (splneno) {
			text = a.getString(R.string.msg_driveway_saved);
		}
		else {
			text = a.getString(R.string.err_driveway_edit_disabled)+"\n"+a.getString(R.string.err_change_settings);
		}

		a.showToast(text);

		a.generateBilanceTables();
		a.popup_window.dismiss();
	}
}
*/
